package com.verisette.ncos.service.master.bizunit;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;

import org.corp.agi.common.exception.ProcessException;
import org.corp.agi.service.bean.ProcessContext;
import org.corp.agi.service.bizunit.CommonBusinessUnit;
import com.verisette.ncos.persistence.dao.UserProfileManagementDAO;
import com.verisette.ncos.persistence.domain.CustomMasterUserProfile;
import com.verisette.ncos.persistence.domain.MasterUserProfile;

public class InquiryUserProfileManagementBU extends CommonBusinessUnit {

	private Logger logger = Logger.getLogger(InquiryUserProfileManagementBU.class);
	
	private UserProfileManagementDAO userProfileManagementDAO;
	@Required
	@Autowired
	public void setUserProfileManagementDAO(UserProfileManagementDAO userProfileManagementDAO) {
		this.userProfileManagementDAO = userProfileManagementDAO;
	} 

	@Override
	public void execute(ProcessContext processContext) throws ProcessException {
		if(logger.isInfoEnabled()) logger.info( this.getClass().getSimpleName() + ": execute" );
		
		// Inquiry UserProfile in MASTER_USER_PROFILE
		logger.debug("1.Inquiry UserProfile in MASTER_USER_PROFILE.");
		
		MasterUserProfile searchBean = (MasterUserProfile)processContext.getValueObject();
		//List<CustomMasterUserProfile> userProfileList = userProfileManagementDAO.inquiryUserProfile(searchBean, processContext.getPaging());
		
		List<CustomMasterUserProfile> userProfileList = userProfileManagementDAO.inquiryUserProfileMergeRole(searchBean, processContext.getPaging());
		
		logger.debug("--> criteria : " + searchBean.getUsername());
		logger.debug("--> result list size : " + userProfileList.size());
		
		processContext.setValueObject(userProfileList);
	}
	
}
